﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using Elentok.Common.Wpf.Dialogs;
using Elentok.Common.Wpf.ViewModels.Dialogs;
using Elentok.Common.Wpf;
using Elentok.Common.Wpf.Services;

namespace AMail.Start
{
  /// <summary>
  /// Interaction logic for App.xaml
  /// </summary>
  public partial class App : Application
  {
    private ICommonDialogsService commonDialogsService;

    protected override void OnStartup(StartupEventArgs e)
    {
      base.OnStartup(e);

      Bootstrapper bootstrapper = new Bootstrapper();
      bootstrapper.Run();
      this.commonDialogsService = bootstrapper.Container.Resolve<ICommonDialogsService>();
    }

    private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
    {
      var viewModel = new ExceptionDialogViewModel(e.Exception);
      viewModel.Show();
      e.Handled = true;
    }
  }
}
